# Metview Macro

line_Lat1 =  50
line_Lon1 = -90
line_Lat2 =  30
line_Lon2 = -60

pressure_axis = maxis(
    axis_orientation      : "vertical",
    axis_title_text       : "Pressure (hPa)",
    axis_title_height     : 0.5,
    axis_title_font_style : "bold"
    )

cross_section_log = mxsectview(
    top_level        : 200,
    vertical_scaling : "log",
    line             : [line_Lat1,line_Lon1,line_Lat2,line_Lon2],
    page_frame       : "off",
    vertical_axis    : pressure_axis
    )

page = plot_page(
    top    : -1.29658076276e-07,
    bottom : 99.9999922409,
    right  : 85,
    view   : cross_section_log
    )

land_sea_shade = mcoast(
    map_coastline_land_shade        : "on",
    map_coastline_land_shade_colour : "RGB(0.98,0.95,0.82)",
    map_coastline_sea_shade         : "on",
    map_coastline_sea_shade_colour  : "background",
    map_grid_line_style             : "dash",
    map_grid_colour                 : "grey",
    map_label_left                  : "off",
    map_label_bottom                : "off"
    )

n_america = geoview(
    map_area_definition : "corners",
    area                : [20,-110,70,-30],
    coastlines          : land_sea_shade
    )

page_1 = plot_page(
    bottom : 25.0000006159,
    left   : 73.0441414628,
    right  : 98.0441419744,
    view   : n_america
    )

display_window = plot_superpage(
    pages : [page,page_1]
    )

vorticity = read("vorticity.grib")

vox100000 = vorticity * 100000

sandy_xs_contour_shading = mcont(
    legend                       : "on",
    contour_highlight            : "off",
    contour_level_selection_type : "level_list",
    contour_level_list           : [-200,-100,-75,-50,-30,-20,-15,-13,-11,-9,-7,-5,-3,-1,1,3,5,7,9,11,13,15,20,30,50,75,100,200],
    contour_label                : "off",
    contour_shade                : "on",
    contour_shade_colour_method  : "list",
    contour_shade_method         : "area_fill",
    contour_shade_colour_list    : ["RGB(0,0,0.3)","RGB(0,0,0.5)","RGB(0,0,0.7)","RGB(0,0,0.9)","RGB(0,0.15,1)","RGB(0,0.3,1)","RGB(0,0.45,1)","RGB(0,0.6,1)","RGB(0,0.75,1)","RGB(0,0.85,1)","RGB(0.2,0.95,1)","RGB(0.45,1,1)","RGB(0.75,1,1)","white","yellow","RGB(1,0.9,0)","RGB(1,0.8,0)","RGB(1,0.7,0)","RGB(1,0.6,0)","RGB(1,0.5,0)","RGB(1,0.4,0)","RGB(1,0.3,0)","RGB(1,0.15,0)","RGB(0.9,0,0)","RGB(0.7,0,0)","RGB(0.5,0,0)","RGB(0.3,0,0)"]
    )

xs_title = mtext(
    text_font_size : 0.5
    )

xs_legend = mlegend(
    legend_box_mode             : "positional",
    legend_text_font_size       : 0.3,
    legend_entry_plot_direction : "column",
    legend_box_x_position       : 24,
    legend_box_y_position       : 1,
    legend_box_x_length         : 2,
    legend_box_y_length         : 15,
    legend_box_blanking         : "on"
    )

xs_line_on_map = input_visualiser(
    input_plot_type        : "geo_points",
    input_longitude_values : [line_Lon1,line_Lon2],
    input_latitude_values  : [line_Lat1,line_Lat2]
    )

map_line_plot = mgraph(
    graph_line_colour    : "black",
    graph_line_thickness : 5
    )


nyc_marker = input_visualiser(
    input_plot_type        : "geo_points",
    input_longitude_values : -74,
    input_latitude_values  : 40.71
    )

nyc_plotting = msymb(
    legend              : "on",
    symbol_type         : "marker",
    legend_user_text    : "NYC",
    symbol_colour       : "red",
    symbol_height       : 0.5,
    symbol_marker_index : 28
    )

map_legend = mlegend(
    legend_display_type   : "disjoint",
    legend_text_font_size : 0.3
    )


plot(display_window[1], vox100000, sandy_xs_contour_shading, xs_title, xs_legend)
plot(display_window[2], xs_line_on_map, map_line_plot, nyc_marker, nyc_plotting, map_legend)
